package com.itheima.redbaby.engine.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.itheima.redbaby.ContantValue;
import com.itheima.redbaby.bean.Product;
import com.itheima.redbaby.engine.BaseEngine;
import com.itheima.redbaby.engine.HotProductEngine;

public class HotProductEngineImpl   extends BaseEngine  implements  HotProductEngine{

	@Override
	public List<Product> HotProductPList(int page, int pageNum) {
		//存放请求参数的map
				Map  <String,Object> requestParams  = new HashMap<String, Object>();
				requestParams.put("page", page);//1 2
				requestParams.put("pageNum",pageNum);
				//获得服务器返回的 json 对象
			 
				JSONObject json = getJson(TYPE_GET, ContantValue.REDBOY_HOTPRODUCTSERVLET, requestParams);
				
				List<Product> topicList = JSONObject.parseArray(json.getString("productlist"), Product.class);
				for (Product product : topicList) {
					System.out.println(product.toString()  );
				}
				
				
				return topicList; 
	}

}
